{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Pandas练习题50题"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    ">作者：王大毛，和鲸社区\n",
    ">\n",
    ">出处：https://www.kesci.com/home/project/5ddc974ef41512002cec1dca\n",
    ">\n",
    ">修改：黄海广"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Pandas 是基于 NumPy 的一种数据处理工具，该工具为了解决数据分析任务而创建。Pandas 纳入了大量库和一些标准的数据模型，提供了高效地操作大型数据集所需的函数和方法。 这些练习着重DataFrame和Series对象的基本操作，包括数据的索引、分组、统计和清洗。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 基本操作\n",
    "### 1.导入 Pandas 库并简写为 pd，并输出版本号"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'0.22.0'"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "pd.__version__"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 2. 从列表创建 Series"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    0\n",
       "1    1\n",
       "2    2\n",
       "3    3\n",
       "4    4\n",
       "dtype: int64"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr = [0, 1, 2, 3, 4]\n",
    "df = pd.Series(arr) # 如果不指定索引，则默认从 0 开始\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 3. 从字典创建 Series"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "a    1\n",
       "b    2\n",
       "c    3\n",
       "d    4\n",
       "e    5\n",
       "dtype: int64"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d = {'a':1,'b':2,'c':3,'d':4,'e':5}\n",
    "df = pd.Series(d)\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 4. 从 NumPy 数组创建 DataFrame"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2020-01-10 22:46:01.642021</th>\n",
       "      <td>0.277099</td>\n",
       "      <td>0.665053</td>\n",
       "      <td>0.882637</td>\n",
       "      <td>-0.598895</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-11 22:46:01.642021</th>\n",
       "      <td>0.365233</td>\n",
       "      <td>-2.529804</td>\n",
       "      <td>-0.699849</td>\n",
       "      <td>0.159623</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-12 22:46:01.642021</th>\n",
       "      <td>-0.831850</td>\n",
       "      <td>-2.099049</td>\n",
       "      <td>-0.976407</td>\n",
       "      <td>-0.342800</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-13 22:46:01.642021</th>\n",
       "      <td>0.680800</td>\n",
       "      <td>1.682999</td>\n",
       "      <td>0.144469</td>\n",
       "      <td>-2.503013</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-14 22:46:01.642021</th>\n",
       "      <td>-0.413880</td>\n",
       "      <td>0.876169</td>\n",
       "      <td>-1.047877</td>\n",
       "      <td>0.996865</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-15 22:46:01.642021</th>\n",
       "      <td>1.373956</td>\n",
       "      <td>0.029732</td>\n",
       "      <td>-0.549268</td>\n",
       "      <td>-0.287584</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                   A         B         C         D\n",
       "2020-01-10 22:46:01.642021  0.277099  0.665053  0.882637 -0.598895\n",
       "2020-01-11 22:46:01.642021  0.365233 -2.529804 -0.699849  0.159623\n",
       "2020-01-12 22:46:01.642021 -0.831850 -2.099049 -0.976407 -0.342800\n",
       "2020-01-13 22:46:01.642021  0.680800  1.682999  0.144469 -2.503013\n",
       "2020-01-14 22:46:01.642021 -0.413880  0.876169 -1.047877  0.996865\n",
       "2020-01-15 22:46:01.642021  1.373956  0.029732 -0.549268 -0.287584"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "dates = pd.date_range('today', periods=6)  # 定义时间序列作为 index\n",
    "num_arr = np.random.randn(6, 4)  # 传入 numpy 随机数组\n",
    "columns = ['A', 'B', 'C', 'D']  # 将列表作为列名\n",
    "df = pd.DataFrame(num_arr, index=dates, columns=columns)\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 5. 从CSV中创建 DataFrame，分隔符为“；”，编码格式为gbk"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "df = pd.read_csv('test.csv', encoding='gbk', sep=';')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 6. 从字典对象创建DataFrame，并设置索引"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>animal</th>\n",
       "      <th>priority</th>\n",
       "      <th>visits</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>2.5</td>\n",
       "      <td>cat</td>\n",
       "      <td>yes</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>b</th>\n",
       "      <td>3.0</td>\n",
       "      <td>cat</td>\n",
       "      <td>yes</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>0.5</td>\n",
       "      <td>snake</td>\n",
       "      <td>no</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>d</th>\n",
       "      <td>NaN</td>\n",
       "      <td>dog</td>\n",
       "      <td>yes</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>e</th>\n",
       "      <td>5.0</td>\n",
       "      <td>dog</td>\n",
       "      <td>no</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>f</th>\n",
       "      <td>2.0</td>\n",
       "      <td>cat</td>\n",
       "      <td>no</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>g</th>\n",
       "      <td>4.5</td>\n",
       "      <td>snake</td>\n",
       "      <td>no</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>h</th>\n",
       "      <td>NaN</td>\n",
       "      <td>cat</td>\n",
       "      <td>yes</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>i</th>\n",
       "      <td>7.0</td>\n",
       "      <td>dog</td>\n",
       "      <td>no</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>j</th>\n",
       "      <td>3.0</td>\n",
       "      <td>dog</td>\n",
       "      <td>no</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   age animal priority  visits\n",
       "a  2.5    cat      yes       1\n",
       "b  3.0    cat      yes       3\n",
       "c  0.5  snake       no       2\n",
       "d  NaN    dog      yes       3\n",
       "e  5.0    dog       no       2\n",
       "f  2.0    cat       no       3\n",
       "g  4.5  snake       no       1\n",
       "h  NaN    cat      yes       1\n",
       "i  7.0    dog       no       2\n",
       "j  3.0    dog       no       1"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "data = {\n",
    "    'animal':\n",
    "    ['cat', 'cat', 'snake', 'dog', 'dog', 'cat', 'snake', 'cat', 'dog', 'dog'],\n",
    "    'age': [2.5, 3, 0.5, np.nan, 5, 2, 4.5, np.nan, 7, 3],\n",
    "    'visits': [1, 3, 2, 3, 2, 3, 1, 1, 2, 1],\n",
    "    'priority':\n",
    "    ['yes', 'yes', 'no', 'yes', 'no', 'no', 'no', 'yes', 'no', 'no']\n",
    "}\n",
    "\n",
    "labels = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']\n",
    "df = pd.DataFrame(data, index=labels)\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 7. 显示df的基础信息，包括行的数量；列名；每一列值的数量、类型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Index: 10 entries, a to j\n",
      "Data columns (total 4 columns):\n",
      "age         8 non-null float64\n",
      "animal      10 non-null object\n",
      "priority    10 non-null object\n",
      "visits      10 non-null int64\n",
      "dtypes: float64(1), int64(1), object(2)\n",
      "memory usage: 400.0+ bytes\n"
     ]
    }
   ],
   "source": [
    "df.info()\n",
    "# 方法二\n",
    "# df.describe()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 8. 展示df的前3行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>animal</th>\n",
       "      <th>priority</th>\n",
       "      <th>visits</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>2.5</td>\n",
       "      <td>cat</td>\n",
       "      <td>yes</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>b</th>\n",
       "      <td>3.0</td>\n",
       "      <td>cat</td>\n",
       "      <td>yes</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>0.5</td>\n",
       "      <td>snake</td>\n",
       "      <td>no</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   age animal priority  visits\n",
       "a  2.5    cat      yes       1\n",
       "b  3.0    cat      yes       3\n",
       "c  0.5  snake       no       2"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.iloc[:3]\n",
    "# 方法二\n",
    "#df.head(3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 9. 取出df的animal和age列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>animal</th>\n",
       "      <th>age</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>cat</td>\n",
       "      <td>2.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>b</th>\n",
       "      <td>cat</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>snake</td>\n",
       "      <td>0.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>d</th>\n",
       "      <td>dog</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>e</th>\n",
       "      <td>dog</td>\n",
       "      <td>5.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>f</th>\n",
       "      <td>cat</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>g</th>\n",
       "      <td>snake</td>\n",
       "      <td>4.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>h</th>\n",
       "      <td>cat</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>i</th>\n",
       "      <td>dog</td>\n",
       "      <td>7.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>j</th>\n",
       "      <td>dog</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  animal  age\n",
       "a    cat  2.5\n",
       "b    cat  3.0\n",
       "c  snake  0.5\n",
       "d    dog  NaN\n",
       "e    dog  5.0\n",
       "f    cat  2.0\n",
       "g  snake  4.5\n",
       "h    cat  NaN\n",
       "i    dog  7.0\n",
       "j    dog  3.0"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[:, ['animal', 'age']]\n",
    "# 方法二\n",
    "# df[['animal', 'age']]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 10. 取出索引为[3, 4, 8]行的animal和age列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>animal</th>\n",
       "      <th>age</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>d</th>\n",
       "      <td>dog</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>e</th>\n",
       "      <td>dog</td>\n",
       "      <td>5.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>i</th>\n",
       "      <td>dog</td>\n",
       "      <td>7.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  animal  age\n",
       "d    dog  NaN\n",
       "e    dog  5.0\n",
       "i    dog  7.0"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[df.index[[3, 4, 8]], ['animal', 'age']]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 11. 取出age值大于3的行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>animal</th>\n",
       "      <th>priority</th>\n",
       "      <th>visits</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>e</th>\n",
       "      <td>5.0</td>\n",
       "      <td>dog</td>\n",
       "      <td>no</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>g</th>\n",
       "      <td>4.5</td>\n",
       "      <td>snake</td>\n",
       "      <td>no</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>i</th>\n",
       "      <td>7.0</td>\n",
       "      <td>dog</td>\n",
       "      <td>no</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   age animal priority  visits\n",
       "e  5.0    dog       no       2\n",
       "g  4.5  snake       no       1\n",
       "i  7.0    dog       no       2"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[df['age'] > 3]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 12. 取出age值缺失的行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>animal</th>\n",
       "      <th>priority</th>\n",
       "      <th>visits</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>d</th>\n",
       "      <td>NaN</td>\n",
       "      <td>dog</td>\n",
       "      <td>yes</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>h</th>\n",
       "      <td>NaN</td>\n",
       "      <td>cat</td>\n",
       "      <td>yes</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   age animal priority  visits\n",
       "d  NaN    dog      yes       3\n",
       "h  NaN    cat      yes       1"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[df['age'].isnull()]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 13.取出age在2,4间的行（不含）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>animal</th>\n",
       "      <th>priority</th>\n",
       "      <th>visits</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>e</th>\n",
       "      <td>5.0</td>\n",
       "      <td>dog</td>\n",
       "      <td>no</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>g</th>\n",
       "      <td>4.5</td>\n",
       "      <td>snake</td>\n",
       "      <td>no</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>i</th>\n",
       "      <td>7.0</td>\n",
       "      <td>dog</td>\n",
       "      <td>no</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   age animal priority  visits\n",
       "e  5.0    dog       no       2\n",
       "g  4.5  snake       no       1\n",
       "i  7.0    dog       no       2"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[(df['age']>2) & (df['age']>4)]\n",
    "# 方法二\n",
    "# df[df['age'].between(2, 4)]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 14. f行的age改为1.5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "df.loc['f', 'age'] = 1.5"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 15. 计算visits的总和"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "19"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['visits'].sum()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 16. 计算每个不同种类animal的age的平均数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "animal\n",
       "cat      2.333333\n",
       "dog      5.000000\n",
       "snake    2.500000\n",
       "Name: age, dtype: float64"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.groupby('animal')['age'].mean()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 17. 在df中插入新行k，然后删除该行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>animal</th>\n",
       "      <th>priority</th>\n",
       "      <th>visits</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>2.5</td>\n",
       "      <td>cat</td>\n",
       "      <td>yes</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>b</th>\n",
       "      <td>3.0</td>\n",
       "      <td>cat</td>\n",
       "      <td>yes</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>0.5</td>\n",
       "      <td>snake</td>\n",
       "      <td>no</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>d</th>\n",
       "      <td>NaN</td>\n",
       "      <td>dog</td>\n",
       "      <td>yes</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>e</th>\n",
       "      <td>5.0</td>\n",
       "      <td>dog</td>\n",
       "      <td>no</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>f</th>\n",
       "      <td>1.5</td>\n",
       "      <td>cat</td>\n",
       "      <td>no</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>g</th>\n",
       "      <td>4.5</td>\n",
       "      <td>snake</td>\n",
       "      <td>no</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>h</th>\n",
       "      <td>NaN</td>\n",
       "      <td>cat</td>\n",
       "      <td>yes</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>i</th>\n",
       "      <td>7.0</td>\n",
       "      <td>dog</td>\n",
       "      <td>no</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>j</th>\n",
       "      <td>3.0</td>\n",
       "      <td>dog</td>\n",
       "      <td>no</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   age animal priority  visits\n",
       "a  2.5    cat      yes       1\n",
       "b  3.0    cat      yes       3\n",
       "c  0.5  snake       no       2\n",
       "d  NaN    dog      yes       3\n",
       "e  5.0    dog       no       2\n",
       "f  1.5    cat       no       3\n",
       "g  4.5  snake       no       1\n",
       "h  NaN    cat      yes       1\n",
       "i  7.0    dog       no       2\n",
       "j  3.0    dog       no       1"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#插入\n",
    "df.loc['k'] = [5.5, 'dog', 'no', 2]\n",
    "# 删除\n",
    "df = df.drop('k')\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 18. 计算df中每个种类animal的数量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dog      4\n",
       "cat      4\n",
       "snake    2\n",
       "Name: animal, dtype: int64"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['animal'].value_counts()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 19. 先按age降序排列，后按visits升序排列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>animal</th>\n",
       "      <th>priority</th>\n",
       "      <th>visits</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>i</th>\n",
       "      <td>7.0</td>\n",
       "      <td>dog</td>\n",
       "      <td>no</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>e</th>\n",
       "      <td>5.0</td>\n",
       "      <td>dog</td>\n",
       "      <td>no</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>g</th>\n",
       "      <td>4.5</td>\n",
       "      <td>snake</td>\n",
       "      <td>no</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>j</th>\n",
       "      <td>3.0</td>\n",
       "      <td>dog</td>\n",
       "      <td>no</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>b</th>\n",
       "      <td>3.0</td>\n",
       "      <td>cat</td>\n",
       "      <td>yes</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>2.5</td>\n",
       "      <td>cat</td>\n",
       "      <td>yes</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>f</th>\n",
       "      <td>1.5</td>\n",
       "      <td>cat</td>\n",
       "      <td>no</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>0.5</td>\n",
       "      <td>snake</td>\n",
       "      <td>no</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>h</th>\n",
       "      <td>NaN</td>\n",
       "      <td>cat</td>\n",
       "      <td>yes</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>d</th>\n",
       "      <td>NaN</td>\n",
       "      <td>dog</td>\n",
       "      <td>yes</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   age animal priority  visits\n",
       "i  7.0    dog       no       2\n",
       "e  5.0    dog       no       2\n",
       "g  4.5  snake       no       1\n",
       "j  3.0    dog       no       1\n",
       "b  3.0    cat      yes       3\n",
       "a  2.5    cat      yes       1\n",
       "f  1.5    cat       no       3\n",
       "c  0.5  snake       no       2\n",
       "h  NaN    cat      yes       1\n",
       "d  NaN    dog      yes       3"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.sort_values(by=['age', 'visits'], ascending=[False, True])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 20. 将priority列中的yes, no替换为布尔值True, False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>animal</th>\n",
       "      <th>priority</th>\n",
       "      <th>visits</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>2.5</td>\n",
       "      <td>cat</td>\n",
       "      <td>True</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>b</th>\n",
       "      <td>3.0</td>\n",
       "      <td>cat</td>\n",
       "      <td>True</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>0.5</td>\n",
       "      <td>snake</td>\n",
       "      <td>False</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>d</th>\n",
       "      <td>NaN</td>\n",
       "      <td>dog</td>\n",
       "      <td>True</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>e</th>\n",
       "      <td>5.0</td>\n",
       "      <td>dog</td>\n",
       "      <td>False</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>f</th>\n",
       "      <td>1.5</td>\n",
       "      <td>cat</td>\n",
       "      <td>False</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>g</th>\n",
       "      <td>4.5</td>\n",
       "      <td>snake</td>\n",
       "      <td>False</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>h</th>\n",
       "      <td>NaN</td>\n",
       "      <td>cat</td>\n",
       "      <td>True</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>i</th>\n",
       "      <td>7.0</td>\n",
       "      <td>dog</td>\n",
       "      <td>False</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>j</th>\n",
       "      <td>3.0</td>\n",
       "      <td>dog</td>\n",
       "      <td>False</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   age animal  priority  visits\n",
       "a  2.5    cat      True       1\n",
       "b  3.0    cat      True       3\n",
       "c  0.5  snake     False       2\n",
       "d  NaN    dog      True       3\n",
       "e  5.0    dog     False       2\n",
       "f  1.5    cat     False       3\n",
       "g  4.5  snake     False       1\n",
       "h  NaN    cat      True       1\n",
       "i  7.0    dog     False       2\n",
       "j  3.0    dog     False       1"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['priority'] = df['priority'].map({'yes': True, 'no': False})\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 21. 将animal列中的snake替换为python"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>animal</th>\n",
       "      <th>priority</th>\n",
       "      <th>visits</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>2.5</td>\n",
       "      <td>cat</td>\n",
       "      <td>True</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>b</th>\n",
       "      <td>3.0</td>\n",
       "      <td>cat</td>\n",
       "      <td>True</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>c</th>\n",
       "      <td>0.5</td>\n",
       "      <td>python</td>\n",
       "      <td>False</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>d</th>\n",
       "      <td>NaN</td>\n",
       "      <td>dog</td>\n",
       "      <td>True</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>e</th>\n",
       "      <td>5.0</td>\n",
       "      <td>dog</td>\n",
       "      <td>False</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>f</th>\n",
       "      <td>1.5</td>\n",
       "      <td>cat</td>\n",
       "      <td>False</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>g</th>\n",
       "      <td>4.5</td>\n",
       "      <td>python</td>\n",
       "      <td>False</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>h</th>\n",
       "      <td>NaN</td>\n",
       "      <td>cat</td>\n",
       "      <td>True</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>i</th>\n",
       "      <td>7.0</td>\n",
       "      <td>dog</td>\n",
       "      <td>False</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>j</th>\n",
       "      <td>3.0</td>\n",
       "      <td>dog</td>\n",
       "      <td>False</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   age  animal  priority  visits\n",
       "a  2.5     cat      True       1\n",
       "b  3.0     cat      True       3\n",
       "c  0.5  python     False       2\n",
       "d  NaN     dog      True       3\n",
       "e  5.0     dog     False       2\n",
       "f  1.5     cat     False       3\n",
       "g  4.5  python     False       1\n",
       "h  NaN     cat      True       1\n",
       "i  7.0     dog     False       2\n",
       "j  3.0     dog     False       1"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['animal'] = df['animal'].replace('snake', 'python')\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 22. 对每种animal的每种不同数量visits，计算平均age，即，返回一个表格，行是aniaml种类，列是visits数量，表格值是行动物种类列访客数量的平均年龄"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>visits</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>animal</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>cat</th>\n",
       "      <td>2.5</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2.25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>dog</th>\n",
       "      <td>3.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>python</th>\n",
       "      <td>4.5</td>\n",
       "      <td>0.5</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "visits    1    2     3\n",
       "animal                \n",
       "cat     2.5  NaN  2.25\n",
       "dog     3.0  6.0   NaN\n",
       "python  4.5  0.5   NaN"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.pivot_table(index='animal', columns='visits', values='age', aggfunc='mean')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 进阶操作\n",
    "### 23. 有一列整数列A的DatraFrame，删除数值重复的行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "    A\n",
      "0   1\n",
      "1   2\n",
      "2   2\n",
      "3   3\n",
      "4   4\n",
      "5   5\n",
      "6   5\n",
      "7   5\n",
      "8   6\n",
      "9   7\n",
      "10  7\n",
      "   A\n",
      "0  1\n",
      "1  2\n",
      "3  3\n",
      "4  4\n",
      "5  5\n",
      "8  6\n",
      "9  7\n"
     ]
    }
   ],
   "source": [
    "df = pd.DataFrame({'A': [1, 2, 2, 3, 4, 5, 5, 5, 6, 7, 7]})\n",
    "print(df)\n",
    "df1 = df.loc[df['A'].shift() != df['A']]\n",
    "# 方法二\n",
    "# df1 = df.drop_duplicates(subset='A')\n",
    "print(df1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 24. 一个全数值DatraFrame，每个数字减去该行的平均数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "          0         1         2\n",
      "0  0.465407  0.152497  0.861174\n",
      "1  0.623682  0.627339  0.495652\n",
      "2  0.835176  0.862376  0.693047\n",
      "3  0.319698  0.306709  0.654063\n",
      "4  0.234855  0.194232  0.438597\n",
      "          0         1         2\n",
      "0 -0.027619 -0.340529  0.368148\n",
      "1  0.041457  0.045115 -0.086572\n",
      "2  0.038310  0.065509 -0.103819\n",
      "3 -0.107125 -0.120114  0.227239\n",
      "4 -0.054373 -0.094996  0.149368\n"
     ]
    }
   ],
   "source": [
    "df = pd.DataFrame(np.random.random(size=(5, 3)))\n",
    "print(df)\n",
    "df1 = df.sub(df.mean(axis=1), axis=0)\n",
    "print(df1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 25. 一个有5列的DataFrame，求哪一列的和最小"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "          a         b         c         d         e\n",
      "0  0.653658  0.730994  0.223025  0.456730  0.288283\n",
      "1  0.937546  0.640995  0.197359  0.671524  0.006035\n",
      "2  0.392762  0.174955  0.053928  0.318634  0.464534\n",
      "3  0.741499  0.197861  0.988105  0.633780  0.914250\n",
      "4  0.469285  0.309043  0.162127  0.032480  0.863017\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'c'"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.DataFrame(np.random.random(size=(5, 5)), columns=list('abcde'))\n",
    "print(df)\n",
    "df.sum().idxmin()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 26. 给定DataFrame，求A列每个值的前3大的B的值的和"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "    A    B\n",
      "0   a   12\n",
      "1   a  345\n",
      "2   a    3\n",
      "3   b    1\n",
      "4   b   45\n",
      "5   c   14\n",
      "6   a    4\n",
      "7   a   52\n",
      "8   b   54\n",
      "9   c   23\n",
      "10  c  235\n",
      "11  c   21\n",
      "12  b   57\n",
      "13  b    3\n",
      "14  c   87\n",
      "A\n",
      "a    409\n",
      "b    156\n",
      "c    345\n",
      "Name: B, dtype: int64\n"
     ]
    }
   ],
   "source": [
    "df = pd.DataFrame({'A': list('aaabbcaabcccbbc'), \n",
    "                   'B': [12,345,3,1,45,14,4,52,54,23,235,21,57,3,87]})\n",
    "print(df)\n",
    "df1 = df.groupby('A')['B'].nlargest(3).sum(level=0)\n",
    "print(df1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 27. 给定DataFrame，有列A, B，A的值在1-100（含），对A列每10步长，求对应的B的和"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "    A   B\n",
      "0   1   1\n",
      "1   2   2\n",
      "2  11  11\n",
      "3  11  11\n",
      "4  33  33\n",
      "5  34  34\n",
      "6  35  35\n",
      "7  40  40\n",
      "8  79  79\n",
      "9  99  99\n",
      "A\n",
      "(0, 10]        3\n",
      "(10, 20]      22\n",
      "(20, 30]       0\n",
      "(30, 40]     142\n",
      "(40, 50]       0\n",
      "(50, 60]       0\n",
      "(60, 70]       0\n",
      "(70, 80]      79\n",
      "(80, 90]       0\n",
      "(90, 100]     99\n",
      "Name: B, dtype: int64\n"
     ]
    }
   ],
   "source": [
    "df = pd.DataFrame({\n",
    "    'A': [1, 2, 11, 11, 33, 34, 35, 40, 79, 99],\n",
    "    'B': [1, 2, 11, 11, 33, 34, 35, 40, 79, 99]\n",
    "})\n",
    "print(df)\n",
    "df1 = df.groupby(pd.cut(df['A'], np.arange(0, 101, 10)))['B'].sum()\n",
    "print(df1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 28. 给定DataFrame，计算每个元素至左边最近的0（或者至开头）的距离，生成新列y"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   X    Y\n",
      "0  7  1.0\n",
      "1  2  2.0\n",
      "2  0  0.0\n",
      "3  3  1.0\n",
      "4  4  2.0\n",
      "5  2  3.0\n",
      "6  5  4.0\n",
      "7  0  0.0\n",
      "8  3  1.0\n",
      "9  4  2.0\n"
     ]
    }
   ],
   "source": [
    "df = pd.DataFrame({'X': [7, 2, 0, 3, 4, 2, 5, 0, 3, 4]})\n",
    "# 方法一\n",
    "x = (df['X'] != 0).cumsum()\n",
    "y = x != x.shift()\n",
    "df['Y'] = y.groupby((y != y.shift()).cumsum()).cumsum()\n",
    "print(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   X  Y\n",
      "0  7  1\n",
      "1  2  2\n",
      "2  0  0\n",
      "3  3  1\n",
      "4  4  2\n",
      "5  2  3\n",
      "6  5  4\n",
      "7  0  0\n",
      "8  3  1\n",
      "9  4  2\n"
     ]
    }
   ],
   "source": [
    "# 方法二\n",
    "df['Y'] = df.groupby((df['X'] == 0).cumsum()).cumcount()\n",
    "first_zero_idx = (df['X'] == 0).idxmax()\n",
    "df['Y'].iloc[0:first_zero_idx] += 1\n",
    "print(df)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 29. 一个全数值的DataFrame，返回最大3个值的坐标"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "          0         1         2\n",
      "0  0.974321  0.454025  0.018815\n",
      "1  0.323491  0.468609  0.834424\n",
      "2  0.340960  0.826835  0.503252\n",
      "3  0.812414  0.202745  0.965168\n",
      "4  0.633172  0.270281  0.915212\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "[(2, 4), (2, 3), (0, 0)]"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.DataFrame(np.random.random(size=(5, 3)))\n",
    "print(df)\n",
    "df.unstack().sort_values()[-3:].index.tolist()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 30. 给定DataFrame，将负值代替为同组的平均值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   grps  vals\n",
      "0     a   -12\n",
      "1     a   345\n",
      "2     a     3\n",
      "3     b     1\n",
      "4     b    45\n",
      "5     c    14\n",
      "6     a     4\n",
      "7     a   -52\n",
      "8     b    54\n",
      "9     c    23\n",
      "10    c  -235\n",
      "11    c    21\n",
      "12    b    57\n",
      "13    b     3\n",
      "14    c    87\n",
      "   grps        vals\n",
      "0     a  117.333333\n",
      "1     a  345.000000\n",
      "2     a    3.000000\n",
      "3     b    1.000000\n",
      "4     b   45.000000\n",
      "5     c   14.000000\n",
      "6     a    4.000000\n",
      "7     a  117.333333\n",
      "8     b   54.000000\n",
      "9     c   23.000000\n",
      "10    c   36.250000\n",
      "11    c   21.000000\n",
      "12    b   57.000000\n",
      "13    b    3.000000\n",
      "14    c   87.000000\n"
     ]
    }
   ],
   "source": [
    "df = pd.DataFrame({\n",
    "    'grps':\n",
    "    list('aaabbcaabcccbbc'),\n",
    "    'vals': [-12, 345, 3, 1, 45, 14, 4, -52, 54, 23, -235, 21, 57, 3, 87]\n",
    "})\n",
    "print(df)\n",
    "\n",
    "\n",
    "def replace(group):\n",
    "    mask = group < 0\n",
    "    group[mask] = group[~mask].mean()\n",
    "    return group\n",
    "\n",
    "\n",
    "df['vals'] = df.groupby(['grps'])['vals'].transform(replace)\n",
    "print(df)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 31. 计算3位滑动窗口的平均值，忽略NAN"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   group  value\n",
      "0      a    1.0\n",
      "1      a    2.0\n",
      "2      b    3.0\n",
      "3      b    NaN\n",
      "4      a    2.0\n",
      "5      b    3.0\n",
      "6      b    NaN\n",
      "7      b    1.0\n",
      "8      a    7.0\n",
      "9      b    3.0\n",
      "10     a    NaN\n",
      "11     b    8.0\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "0     1.000000\n",
       "1     1.500000\n",
       "2     3.000000\n",
       "3     3.000000\n",
       "4     1.666667\n",
       "5     3.000000\n",
       "6     3.000000\n",
       "7     2.000000\n",
       "8     3.666667\n",
       "9     2.000000\n",
       "10    4.500000\n",
       "11    4.000000\n",
       "Name: value, dtype: float64"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.DataFrame({\n",
    "    'group': list('aabbabbbabab'),\n",
    "    'value': [1, 2, 3, np.nan, 2, 3, np.nan, 1, 7, 3, np.nan, 8]\n",
    "})\n",
    "print(df)\n",
    "\n",
    "g1 = df.groupby(['group'])['value']\n",
    "g2 = df.fillna(0).groupby(['group'])['value']\n",
    "\n",
    "s = g2.rolling(3, min_periods=1).sum() / g1.rolling(3, min_periods=1).count()\n",
    "s.reset_index(level=0, drop=True).sort_index()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Series 和 Datetime索引\n",
    "### 32. 创建Series s，将2015所有工作日作为随机值的索引"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2015-01-01    0.503458\n",
       "2015-01-02    0.194185\n",
       "2015-01-05    0.550930\n",
       "2015-01-06    0.174309\n",
       "2015-01-07    0.316911\n",
       "2015-01-08    0.288385\n",
       "2015-01-09    0.293285\n",
       "2015-01-12    0.340436\n",
       "2015-01-13    0.630009\n",
       "2015-01-14    0.076130\n",
       "Freq: B, dtype: float64"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dti = pd.date_range(start='2015-01-01', end='2015-12-31', freq='B') \n",
    "s = pd.Series(np.random.rand(len(dti)), index=dti)\n",
    "\n",
    "s.head(10)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 33. 所有礼拜三的值求和"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "27.272318047689705"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s[s.index.weekday == 2].sum()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 34. 求每个自然月的平均数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2015-01-31    0.375417\n",
       "2015-02-28    0.551560\n",
       "2015-03-31    0.540772\n",
       "2015-04-30    0.450957\n",
       "2015-05-31    0.369119\n",
       "2015-06-30    0.588625\n",
       "2015-07-31    0.584358\n",
       "2015-08-31    0.609751\n",
       "2015-09-30    0.511285\n",
       "2015-10-31    0.555546\n",
       "2015-11-30    0.528777\n",
       "2015-12-31    0.574317\n",
       "Freq: M, dtype: float64"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s.resample('M').mean()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 35. 每连续4个月为一组，求最大值所在的日期"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2015-01-31   2015-01-15\n",
       "2015-05-31   2015-02-04\n",
       "2015-09-30   2015-06-02\n",
       "2016-01-31   2015-12-08\n",
       "dtype: datetime64[ns]"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s.groupby(pd.Grouper(freq='4M')).idxmax()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 36. 创建2015-2016每月第三个星期四的序列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Airline</th>\n",
       "      <th>FlightNumber</th>\n",
       "      <th>From_To</th>\n",
       "      <th>RecentDelays</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>KLM(!)</td>\n",
       "      <td>10045.0</td>\n",
       "      <td>LoNDon_paris</td>\n",
       "      <td>[23, 47]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>&lt;Air France&gt; (12)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>MAdrid_miLAN</td>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>(British Airways. )</td>\n",
       "      <td>10065.0</td>\n",
       "      <td>londON_StockhOlm</td>\n",
       "      <td>[24, 43, 87]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>12. Air France</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Budapest_PaRis</td>\n",
       "      <td>[13]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>\"Swiss Air\"</td>\n",
       "      <td>10085.0</td>\n",
       "      <td>Brussels_londOn</td>\n",
       "      <td>[67, 32]</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               Airline  FlightNumber           From_To  RecentDelays\n",
       "0               KLM(!)       10045.0      LoNDon_paris      [23, 47]\n",
       "1    <Air France> (12)           NaN      MAdrid_miLAN            []\n",
       "2  (British Airways. )       10065.0  londON_StockhOlm  [24, 43, 87]\n",
       "3       12. Air France           NaN    Budapest_PaRis          [13]\n",
       "4          \"Swiss Air\"       10085.0   Brussels_londOn      [67, 32]"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.date_range('2015-01-01', '2016-12-31', freq='WOM-3THU')\n",
    "#数据清洗\n",
    "df = pd.DataFrame({'From_To': ['LoNDon_paris', 'MAdrid_miLAN', 'londON_StockhOlm', \n",
    "                               'Budapest_PaRis', 'Brussels_londOn'],\n",
    "              'FlightNumber': [10045, np.nan, 10065, np.nan, 10085],\n",
    "              'RecentDelays': [[23, 47], [], [24, 43, 87], [13], [67, 32]],\n",
    "                   'Airline': ['KLM(!)', '<Air France> (12)', '(British Airways. )', \n",
    "                               '12. Air France', '\"Swiss Air\"']})\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 37. FlightNumber列中有些值缺失了，他们本来应该是每一行增加10，填充缺失的数值，并且令数据类型为整数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Airline</th>\n",
       "      <th>FlightNumber</th>\n",
       "      <th>From_To</th>\n",
       "      <th>RecentDelays</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>KLM(!)</td>\n",
       "      <td>10045</td>\n",
       "      <td>LoNDon_paris</td>\n",
       "      <td>[23, 47]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>&lt;Air France&gt; (12)</td>\n",
       "      <td>10055</td>\n",
       "      <td>MAdrid_miLAN</td>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>(British Airways. )</td>\n",
       "      <td>10065</td>\n",
       "      <td>londON_StockhOlm</td>\n",
       "      <td>[24, 43, 87]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>12. Air France</td>\n",
       "      <td>10075</td>\n",
       "      <td>Budapest_PaRis</td>\n",
       "      <td>[13]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>\"Swiss Air\"</td>\n",
       "      <td>10085</td>\n",
       "      <td>Brussels_londOn</td>\n",
       "      <td>[67, 32]</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               Airline  FlightNumber           From_To  RecentDelays\n",
       "0               KLM(!)         10045      LoNDon_paris      [23, 47]\n",
       "1    <Air France> (12)         10055      MAdrid_miLAN            []\n",
       "2  (British Airways. )         10065  londON_StockhOlm  [24, 43, 87]\n",
       "3       12. Air France         10075    Budapest_PaRis          [13]\n",
       "4          \"Swiss Air\"         10085   Brussels_londOn      [67, 32]"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['FlightNumber'] = df['FlightNumber'].interpolate().astype(int)\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 38. 将From_To列从_分开，分成From, To两列，并删除原始列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Airline</th>\n",
       "      <th>FlightNumber</th>\n",
       "      <th>RecentDelays</th>\n",
       "      <th>From</th>\n",
       "      <th>To</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>KLM(!)</td>\n",
       "      <td>10045</td>\n",
       "      <td>[23, 47]</td>\n",
       "      <td>LoNDon</td>\n",
       "      <td>paris</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>&lt;Air France&gt; (12)</td>\n",
       "      <td>10055</td>\n",
       "      <td>[]</td>\n",
       "      <td>MAdrid</td>\n",
       "      <td>miLAN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>(British Airways. )</td>\n",
       "      <td>10065</td>\n",
       "      <td>[24, 43, 87]</td>\n",
       "      <td>londON</td>\n",
       "      <td>StockhOlm</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>12. Air France</td>\n",
       "      <td>10075</td>\n",
       "      <td>[13]</td>\n",
       "      <td>Budapest</td>\n",
       "      <td>PaRis</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>\"Swiss Air\"</td>\n",
       "      <td>10085</td>\n",
       "      <td>[67, 32]</td>\n",
       "      <td>Brussels</td>\n",
       "      <td>londOn</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               Airline  FlightNumber  RecentDelays      From         To\n",
       "0               KLM(!)         10045      [23, 47]    LoNDon      paris\n",
       "1    <Air France> (12)         10055            []    MAdrid      miLAN\n",
       "2  (British Airways. )         10065  [24, 43, 87]    londON  StockhOlm\n",
       "3       12. Air France         10075          [13]  Budapest      PaRis\n",
       "4          \"Swiss Air\"         10085      [67, 32]  Brussels     londOn"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "temp = df.From_To.str.split('_', expand=True)\n",
    "temp.columns = ['From', 'To']\n",
    "df = df.join(temp)\n",
    "df = df.drop('From_To', axis=1)\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 39. 将From, To大小写统一首字母大写其余小写"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Airline</th>\n",
       "      <th>FlightNumber</th>\n",
       "      <th>RecentDelays</th>\n",
       "      <th>From</th>\n",
       "      <th>To</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>KLM(!)</td>\n",
       "      <td>10045</td>\n",
       "      <td>[23, 47]</td>\n",
       "      <td>London</td>\n",
       "      <td>Paris</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>&lt;Air France&gt; (12)</td>\n",
       "      <td>10055</td>\n",
       "      <td>[]</td>\n",
       "      <td>Madrid</td>\n",
       "      <td>Milan</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>(British Airways. )</td>\n",
       "      <td>10065</td>\n",
       "      <td>[24, 43, 87]</td>\n",
       "      <td>London</td>\n",
       "      <td>Stockholm</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>12. Air France</td>\n",
       "      <td>10075</td>\n",
       "      <td>[13]</td>\n",
       "      <td>Budapest</td>\n",
       "      <td>Paris</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>\"Swiss Air\"</td>\n",
       "      <td>10085</td>\n",
       "      <td>[67, 32]</td>\n",
       "      <td>Brussels</td>\n",
       "      <td>London</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               Airline  FlightNumber  RecentDelays      From         To\n",
       "0               KLM(!)         10045      [23, 47]    London      Paris\n",
       "1    <Air France> (12)         10055            []    Madrid      Milan\n",
       "2  (British Airways. )         10065  [24, 43, 87]    London  Stockholm\n",
       "3       12. Air France         10075          [13]  Budapest      Paris\n",
       "4          \"Swiss Air\"         10085      [67, 32]  Brussels     London"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['From'] = df['From'].str.capitalize()\n",
    "df['To'] = df['To'].str.capitalize()\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 40. Airline列，有一些多余的标点符号，需要提取出正确的航司名称。举例：'(British Airways. )' 应该改为 'British Airways'."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Airline</th>\n",
       "      <th>FlightNumber</th>\n",
       "      <th>RecentDelays</th>\n",
       "      <th>From</th>\n",
       "      <th>To</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>KLM</td>\n",
       "      <td>10045</td>\n",
       "      <td>[23, 47]</td>\n",
       "      <td>London</td>\n",
       "      <td>Paris</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Air France</td>\n",
       "      <td>10055</td>\n",
       "      <td>[]</td>\n",
       "      <td>Madrid</td>\n",
       "      <td>Milan</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>British Airways</td>\n",
       "      <td>10065</td>\n",
       "      <td>[24, 43, 87]</td>\n",
       "      <td>London</td>\n",
       "      <td>Stockholm</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Air France</td>\n",
       "      <td>10075</td>\n",
       "      <td>[13]</td>\n",
       "      <td>Budapest</td>\n",
       "      <td>Paris</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Swiss Air</td>\n",
       "      <td>10085</td>\n",
       "      <td>[67, 32]</td>\n",
       "      <td>Brussels</td>\n",
       "      <td>London</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           Airline  FlightNumber  RecentDelays      From         To\n",
       "0              KLM         10045      [23, 47]    London      Paris\n",
       "1       Air France         10055            []    Madrid      Milan\n",
       "2  British Airways         10065  [24, 43, 87]    London  Stockholm\n",
       "3       Air France         10075          [13]  Budapest      Paris\n",
       "4        Swiss Air         10085      [67, 32]  Brussels     London"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['Airline'] = df['Airline'].str.extract(\n",
    "    '([a-zA-Z\\s]+)', expand=False).str.strip()\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 41. Airline列，数据被以列表的形式录入，但是我们希望每个数字被录入成单独一列，delay_1, delay_2, ...没有的用NAN替代。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Airline</th>\n",
       "      <th>FlightNumber</th>\n",
       "      <th>From</th>\n",
       "      <th>To</th>\n",
       "      <th>delay_1</th>\n",
       "      <th>delay_2</th>\n",
       "      <th>delay_3</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>KLM</td>\n",
       "      <td>10045</td>\n",
       "      <td>London</td>\n",
       "      <td>Paris</td>\n",
       "      <td>23.0</td>\n",
       "      <td>47.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Air France</td>\n",
       "      <td>10055</td>\n",
       "      <td>Madrid</td>\n",
       "      <td>Milan</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>British Airways</td>\n",
       "      <td>10065</td>\n",
       "      <td>London</td>\n",
       "      <td>Stockholm</td>\n",
       "      <td>24.0</td>\n",
       "      <td>43.0</td>\n",
       "      <td>87.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Air France</td>\n",
       "      <td>10075</td>\n",
       "      <td>Budapest</td>\n",
       "      <td>Paris</td>\n",
       "      <td>13.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Swiss Air</td>\n",
       "      <td>10085</td>\n",
       "      <td>Brussels</td>\n",
       "      <td>London</td>\n",
       "      <td>67.0</td>\n",
       "      <td>32.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           Airline  FlightNumber      From         To  delay_1  delay_2  \\\n",
       "0              KLM         10045    London      Paris     23.0     47.0   \n",
       "1       Air France         10055    Madrid      Milan      NaN      NaN   \n",
       "2  British Airways         10065    London  Stockholm     24.0     43.0   \n",
       "3       Air France         10075  Budapest      Paris     13.0      NaN   \n",
       "4        Swiss Air         10085  Brussels     London     67.0     32.0   \n",
       "\n",
       "   delay_3  \n",
       "0      NaN  \n",
       "1      NaN  \n",
       "2     87.0  \n",
       "3      NaN  \n",
       "4      NaN  "
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "delays = df['RecentDelays'].apply(pd.Series)\n",
    "delays.columns = ['delay_{}'.format(n) for n in range(1, len(delays.columns)+1)]\n",
    "df = df.drop('RecentDelays', axis=1).join(delays)\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 层次化索引\n",
    "### 42. 用 letters = ['A', 'B', 'C']和 numbers = list(range(10))的组合作为系列随机值的层次化索引"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "A  0    0.250785\n",
       "   1    0.146978\n",
       "   2    0.596062\n",
       "   3    0.064608\n",
       "B  0    0.709660\n",
       "   1    0.515778\n",
       "   2    0.483163\n",
       "   3    0.524490\n",
       "C  0    0.360434\n",
       "   1    0.987620\n",
       "   2    0.527151\n",
       "   3    0.636960\n",
       "dtype: float64"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "letters = ['A', 'B', 'C']\n",
    "numbers = list(range(4))\n",
    "\n",
    "mi = pd.MultiIndex.from_product([letters, numbers])\n",
    "s = pd.Series(np.random.rand(12), index=mi)\n",
    "s"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 43. 检查s是否是字典顺序排序的"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s.index.is_lexsorted()\n",
    "# 方法二\n",
    "# s.index.lexsort_depth == s.index.nlevels"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 44. 选择二级索引为1, 3的行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "A  1    0.146978\n",
       "   3    0.064608\n",
       "B  1    0.515778\n",
       "   3    0.524490\n",
       "C  1    0.987620\n",
       "   3    0.636960\n",
       "dtype: float64"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s.loc[:, [1, 3]]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 45. 对s进行切片操作，取一级索引至B，二级索引从2开始到最后"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "A  2    0.596062\n",
       "   3    0.064608\n",
       "B  2    0.483163\n",
       "   3    0.524490\n",
       "dtype: float64"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s.loc[pd.IndexSlice[:'B', 2:]]\n",
    "# 方法二\n",
    "# s.loc[slice(None, 'B'), slice(2, None)]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 46. 计算每个一级索引的和（A, B, C每一个的和）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "A    1.058433\n",
       "B    2.233091\n",
       "C    2.512164\n",
       "dtype: float64"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s.sum(level=0)\n",
    "#方法二\n",
    "#s.unstack().sum(axis=0)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 47. 交换索引等级，新的Series是字典顺序吗？不是的话请排序"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0  A    0.250785\n",
      "1  A    0.146978\n",
      "2  A    0.596062\n",
      "3  A    0.064608\n",
      "0  B    0.709660\n",
      "1  B    0.515778\n",
      "2  B    0.483163\n",
      "3  B    0.524490\n",
      "0  C    0.360434\n",
      "1  C    0.987620\n",
      "2  C    0.527151\n",
      "3  C    0.636960\n",
      "dtype: float64\n",
      "False\n",
      "0  A    0.250785\n",
      "   B    0.709660\n",
      "   C    0.360434\n",
      "1  A    0.146978\n",
      "   B    0.515778\n",
      "   C    0.987620\n",
      "2  A    0.596062\n",
      "   B    0.483163\n",
      "   C    0.527151\n",
      "3  A    0.064608\n",
      "   B    0.524490\n",
      "   C    0.636960\n",
      "dtype: float64\n"
     ]
    }
   ],
   "source": [
    "new_s = s.swaplevel(0, 1)\n",
    "print(new_s)\n",
    "print(new_s.index.is_lexsorted())\n",
    "new_s = new_s.sort_index()\n",
    "print(new_s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [],
   "source": [
    "## 可视化\n",
    "import matplotlib.pyplot as plt\n",
    "df = pd.DataFrame({\"xs\": [1, 5, 2, 8, 1], \"ys\": [4, 2, 1, 9, 6]})\n",
    "plt.style.use('ggplot')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 48. 画出df的散点图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x1f188ddacc0>"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX8AAAENCAYAAADnrmWtAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0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ltmbo7++3WGa9JXTTfRWT0KPHraM7+7GT4YzLK3AA9m5temHeQsrgP+LDOfyMxvA/cAb5jkQMt/SiKiBXwUOJGZvzjtPGcTEZeMzvAgIi5i+If65emm2ltm/lxmXpqZlzF8uv/7mTnRo6iDiogXRsSLT34PvBn4k+mm2ltmfhX4y9GZNDBcS5+516me4+3M8JLPyCPA1RFx8agbrmXCL6SfV+U/ulD8Z4FXRsSjEfHuaWc6i2uAdzI8Kn1o9PXj0w61hx8A/iAivgB8DtjIzE9OOdP54qXAZyLiYeCPgfXM/NSUM53LLcBdo7+HK4F/O+U8e4qIi4EVhkfSM2v0TOpu4EGGp3lewITf6es7fCWpQOfVkb8kaTyWvyQVyPKXpAJZ/pJUIMtfkgpk+UtSgSx/SSqQ5S9JBfJTPaU9RMTfYviO5usy88GIWAa+APwkcBnwIeASYAv4V5l517SySvvlkb+0h8z8CvCzDD/K4GLgVxheMOhzwL8H3pKZL2b4AVwPTSundBB+vIN0DhHxPxh+1G4F/F2Gz5gfA94N/G5mPjPFeNKBeOQvndtHGF6v9j9k5rdGFy55G/DPgccjYj0iXjXVhNI+eeQvncXoYjsPA3/A8HPhX5OZ3zjt3y8Cfh64KjN/ZDoppf3zBV/p7O4EHsjMTkQcB345Im4B/h7wewwvufcU8J0pZpT2zfKX9hARb2V4xbLXjO56P8MXdq8D1oBfZ/g6wEPAe6aRUTool30kqUC+4CtJBbL8JalAlr8kFcjyl6QCWf6SVCDLX5IKZPlLUoEsf0kqkOUvSQX6/9GREqwjeZ/lAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1f18862bf60>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "df.plot.scatter(\"xs\", \"ys\", color = \"black\", marker = \"x\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 49. 可视化指定4维DataFrame"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x1f18aea4c18>"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX8AAAENCAYAAADnrmWtAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3Xt0ZGWZ7/FvVe1KUqmkc+mAdECEHlAU5abD4eAoDDhzUBgZGX0OzmqcaS/NDCiinNGRYUYdl+Ocs5AjB7S1BW+jII8tPTpyVRFYM0A70op4QDnQCE13Y6eTTud+qcv5oyohHdJJ7aRqVyX1+6yVlaRq7/3+VnXnqbfevff7xvL5PCIiUl/i1Q4gIiLRU/EXEalDKv4iInVIxV9EpA6p+IuI1CEVfxGROqTiLyJSh1T8RUTqkIq/iEgdCqodYB669VhEJLxYKRvVcvFn165di963q6uLvXv3ljHN0tViJlCusJQrnFrMVYuZYOm5uru7S962pov/SpBIJEin0yQSCYIgoKOjg0wmw9DQEJpXSUSqRcW/QhoaGmhpaSGZTJJIJKYfT6VS098nJycZHBwkk8lUK6aI1CkV/wpoaWmZ7u0fTBAEBEFAMplkYGCAsbGxCBOKSL3T1T5llk6nFyz8MwVBQFtbG42NjRVOJiLyAhX/MgqCgJaWlpIL/5REIsGqVauIxUo6SS8ismQq/mW0mMI/JQgC0ul0mROJiMwtsjF/M/sg8D4K16B+2d0/F1XbUYjFYjQ0NCxp/6amJoaGhsqYSkRkbpH0/M3s1RQK/6nAicB5ZnZsFG1HJZVKLbrXP2XqJLCISKVFNezzSuAhdx9x9wxwH/C2iNqORBAESx6zj8fjS34DEREpRSyKG43M7JXA94D/CowCPwZ+5u4fmLXdBmADgLu/dmJiYtFtBkEQ6fXziUSi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LBx0I4WFcCaBH7v7f18gWx441t2fNLOvUZiF8ygKc/I/Bvy5uz9VjtdBZD7q+ctKZRRmKD0aOAH4SzM7C/hM8bk1wDMUZg4t1X+hMHfOocCngU8BdwMdFKbEvm4ROd8JfLJ4jCeLxxWpOH10lZXq/0xNv2xm/0ahd/77wFemVlUzs48B+4q9/lLscvepAp8xs0kKnyy63f05Cp8kwrrV3X9azPMtoGZmfZWVTT1/Wamen/HzCNBCYfGO6aUEi0tY9lL6kpo7Zv3+EQqLbf/UzP6vmb27TDlFKk49f6knuyj01IHpOflXAzspjL1DYU3XqVXWDpu1/wEnyIpz6b+veKw/AH5kZve7+5Pljy5SXir+Uk9uAr5tZjdRWMDjn4Ct7v5bADPbCawzsy9ROKn7e/MdzMzeATxYHPLZR+HNIVu5+CLlo2EfqRvu/mPg7yksp7mbQnG/cMYm7wP+hsJQ0PHAAwsc8veBrWY2BHyfwsLpT5c7t0gl6FJPEZE6pJ6/iEgd0pi/SBmZ2RuAO+Z6TlM7SC3RsI+ISB3SsI+ISB1S8RcRqUMq/iIidUjFX0SkDqn4i4jUof8PCv5MRcVAQOQAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1f18aebb6a0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "df = pd.DataFrame({\n",
    "    \"productivity\": [5, 2, 3, 1, 4, 5, 6, 7, 8, 3, 4, 8, 9],\n",
    "    \"hours_in\": [1, 9, 6, 5, 3, 9, 2, 9, 1, 7, 4, 2, 2],\n",
    "    \"happiness\": [2, 1, 3, 2, 3, 1, 2, 3, 1, 2, 2, 1, 3],\n",
    "    \"caffienated\": [0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0]\n",
    "})\n",
    "\n",
    "df.plot.scatter(\n",
    "    \"hours_in\", \"productivity\", s=df.happiness * 100, c=df.caffienated)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 50. 在同一个图中可视化2组数据，共用X轴，但y轴不同"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(-1, 12)"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYcAAAENCAYAAADkNanAAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3Xl8VNX5+PHPnQSSsEPCnrBDgSKCgKJURBbZkSoc8GuRuoEKFFq/ha+i+KvWpQoKFVuLBYVWgYdFxB2K4FJAURRQEWSHhC1sYUtIMvf3x52EbGSdLTPP+/XKi8zMvfc8N2HyzHPPPedYtm2jlFJK5eQKdABKKaWCjyYHpZRS+WhyUEoplY8mB6WUUvloclBKKZWPJgellFL5aHJQSimVjyYHpZRS+WhyUEoplU+kn9vT4dhKKVU6lj8b83dyICkpyd9NKqVUudagQQO/t6mXlZRSSuWjyUEppVQ+mhyUUkrl4/c+B6VU0WzbJjU1FbfbjWX5tR9SBYht27hcLqKjo4Pid67JQakglJqaSoUKFYiM1LdoOMnIyCA1NZWYmJhAh6KXlZQKRm63WxNDGIqMjMTtdgc6DECTg1JBKRguK6jACJbfvSYH5Re2OxP3hrXY588FOhSlVDFo3ar8wt6wDvuNWdi/7Ijrd09gufRzSUk0fK2hV4+XeH+iV4+nQo8mB+VzdmYm9vuLoVJl+OFb7I+WYQ0YXubjluYPpv5RLB3btrPvplHhQX/Tyufsjevg+BFcd0/E6nIj9oo3sXf+EOiwVBEOHjzITTfdxCOPPELfvn1ZunQpgwcPpm/fvowZM4bz58/zySefMHbs2Ox91q9fz+jRowH49NNP820PcN111zF9+nT69u1Lr1692LVrFwAzZszg1VdfzT5W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kyUEppVQ+OghOlWue+ZpeAUYBzXHmbnoUZ+79X+HMZDtcRE4ZY4YAz+LM1vsd8KBnQris48wG7gIa40wONxpn9HgyzoJIFzzNtgLG4Kwbkooz9fQBYHQoLfaiwptWDioU3A70wfmjPRj4ECdBxOH8H/+dMaYVzlw+k3CmOvgAeNczD1cWgzPxYFOgPfBbETmPM/ldkohU8XxlTeg4BCcZ1cCZy2e2T89SKT/S5KBCwcsictSzNsHnwJci8q1nfqC3cdbCGAG8LyKrPbOPTgdiyD0D6V9FJMkzB8+7OKvjFeYLEflARDKBf+GscKZUSNDkoEJBzumsLxbwuArOWgXZK6mJiBtnUrucC0IdyfH9Bc9+hcm7fbRnNTWlyj1NDipcJOH0JQDZU6InAInF2Fc75lTY0eSgwoUAA40xvTyLKD0MpAHri7HvUSDWGFPdlwEqFUw0Oaiw4FkE/jc4c+8n43RcDxaRS8XY9yeczuw9xpjTxpgGPg1WqSCgt7IqpZTKRysHpZRS+WhyUEoplY8mB6WUUvloclBKKZWPJgellFL5aHJQSimVjyYHpZRS+WhyUEoplY8mB6WUUvn8f7iJjJqNH6qqAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1f18af1bb70>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "df = pd.DataFrame({\n",
    "    \"revenue\": [57, 68, 63, 71, 72, 90, 80, 62, 59, 51, 47, 52],\n",
    "    \"advertising\":\n",
    "    [2.1, 1.9, 2.7, 3.0, 3.6, 3.2, 2.7, 2.4, 1.8, 1.6, 1.3, 1.9],\n",
    "    \"month\":\n",
    "    range(12)\n",
    "})\n",
    "\n",
    "ax = df.plot.bar(\"month\", \"revenue\", color=\"green\")\n",
    "df.plot.line(\"month\", \"advertising\", secondary_y=True, ax=ax)\n",
    "ax.set_xlim((-1, 12))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
